using System.Data;
namespace WPFExcelReport
{
    public partial class VAMMODUL
    {
        public void SetUpNewRow(ref DataRow dwReturn)
        {
            #region
            #endregion
            switch (app.company)
            {
                case "YGR":
                case "SXN":
                case "TST":
                case "UBT":
                default:
                    #region
                    dwReturn["AMMMANDANT"] = "00";
                    dwReturn["AMMNRKRS"] = "M ";
                    dwReturn["AMMLFDNR"] = "0036";
                    dwReturn["AMMPOS"] = "00";
                    dwReturn["AMMMODNR"] = "010";
                    dwReturn["AMMBEZ"] = "                                        ";
                    dwReturn["AMMTYP"] = "        ";
                    dwReturn["AMMART"] = "        ";
                    dwReturn["AMMLIEFNR"] = "        ";
                    dwReturn["AMMHERST"] = "                    ";
                    dwReturn["AMMINVNR"] = "      ";
                    dwReturn["AMMINVPOS"] = "  ";
                    dwReturn["AMMABSCHKZ"] = "N";
                    dwReturn["AMMABREITEV"] = "0";
                    dwReturn["AMMABREITEB"] = "0";
                    dwReturn["AMMFLMIN"] = "0";
                    dwReturn["AMMFLMAX"] = "0";
                    dwReturn["AMMSYSFL"] = "0";
                    dwReturn["AMMANSRUND"] = "0";
                    dwReturn["AMMRAKELKZ"] = "N";
                    dwReturn["AMMLAENGE"] = "0";
                    dwReturn["AMMLTRV1"] = "0";
                    dwReturn["AMMLTRB1"] = "0";
                    dwReturn["AMMBHSYS1"] = "00";
                    dwReturn["AMMBHMAX1"] = "00";
                    dwReturn["AMMLTRV2"] = "0";
                    dwReturn["AMMLTRB2"] = "0";
                    dwReturn["AMMBHSYS2"] = "00";
                    dwReturn["AMMBHMAX2"] = "00";
                    dwReturn["AMMLTRV3"] = "0";
                    dwReturn["AMMLTRB3"] = "0";
                    dwReturn["AMMBHSYS3"] = "00";
                    dwReturn["AMMBHMAX3"] = "00";
                    dwReturn["AMMNETFA"] = " ";
                    dwReturn["AMMFILLER"] = "                                                                                              ";
                    dwReturn["AMMAENDZL"] = "0";
                    dwReturn["AMMAENDBEN"] = "        ";
                    dwReturn["AMMAENDDAT"] = "0";
                    dwReturn["AMMNEUBEN"] = "INTEXE  ";
                    dwReturn["AMMNEUDAT"] = "20141023";
                    #endregion
                    break;
            }
        }

        public void InsertAMMODUL(DataRow dwData, string ITXDBVERSION = "50.24")
        {
            dwData["AMMNEUBEN"] = app.company;
            dwData["AMMNEUDAT"] = date;
            or1 = OracleDB.CreateCommand();
            switch (app.company)
            {
                case "YGR":
                case "SXN":
                case "TST":
                case "UBT":
                default:
                    or1.CommandText = "INSERT INTO AMMODUL ( AMMMANDANT,AMMNRKRS,AMMLFDNR,AMMPOS,AMMMODNR,AMMBEZ,AMMTYP,AMMART,AMMLIEFNR,AMMHERST,AMMINVNR,AMMINVPOS,AMMABSCHKZ,AMMABREITEV,AMMABREITEB,AMMFLMIN,AMMFLMAX,AMMSYSFL,AMMANSRUND,AMMRAKELKZ,AMMLAENGE,AMMLTRV1,AMMLTRB1,AMMBHSYS1,AMMBHMAX1,AMMLTRV2,AMMLTRB2,AMMBHSYS2,AMMBHMAX2,AMMLTRV3,AMMLTRB3,AMMBHSYS3,AMMBHMAX3,AMMNETFA,AMMFILLER,AMMAENDZL,AMMAENDBEN,AMMAENDDAT,AMMNEUBEN,AMMNEUDAT)"
                        + " VALUES (:AMMMANDANT:,:AMMNRKRS:,:AMMLFDNR:,:AMMPOS:,:AMMMODNR:,:AMMBEZ:,:AMMTYP:,:AMMART:,:AMMLIEFNR:,:AMMHERST:,:AMMINVNR:,:AMMINVPOS:,:AMMABSCHKZ:,:AMMABREITEV:,:AMMABREITEB:,:AMMFLMIN:,:AMMFLMAX:,:AMMSYSFL:,:AMMANSRUND:,:AMMRAKELKZ:,:AMMLAENGE:,:AMMLTRV1:,:AMMLTRB1:,:AMMBHSYS1:,:AMMBHMAX1:,:AMMLTRV2:,:AMMLTRB2:,:AMMBHSYS2:,:AMMBHMAX2:,:AMMLTRV3:,:AMMLTRB3:,:AMMBHSYS3:,:AMMBHMAX3:,:AMMNETFA:,:AMMFILLER:,:AMMAENDZL:,:AMMAENDBEN:,:AMMAENDDAT:,:AMMNEUBEN:,:AMMNEUDAT:)";
                    or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
                    break;
            }
            Connect2Proxy(or1);
        }
        public DataSet QAMD01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT M.* FROM  AMMODUL M"
                            + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:  AND  AMMLFDNR=:AMMLFDNR:  AND  AMMPOS=:AMMPOS:  AND AMMMODNR=:AMMMODNR:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAMD02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT AMMMODNR AS KEY, AMMBEZ AS DES,M.* FROM  AMMODUL M"
                               + " WHERE AMMMANDANT=:AMMMANDANT:  "
                 + dwData["AMMNRKRS"].ToString()
                + dwData["AMMLFDNR"].ToString()
                + dwData["AMMPOS"].ToString()
                + dwData["AMMMODNR"].ToString()
                ;
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAMD03(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT X.* FROM  AMMODUL JOIN AMSTAMM P ON AMMMANDANT=P.AMMANDANT AND AMMNRKRS=P.AMNRKRS AND  AMMLFDNR=P.AMLFDNR  AND  AMMPOS=P.AMPOS "
                            + " JOIN AMSTAMM X ON X.AMMANDANT=P.AMMANDANT AND X.AMART=P.AMART AND  X.AMTYP=P.AMTYP AND X.AMMANDANT||X.AMNRKRS||X.AMLFDNR||X.AMPOS<>AMMMANDANT||AMMNRKRS||AMMLFDNR||AMMPOS "
                            + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:  AND  AMMLFDNR=:AMMLFDNR:  AND  AMMPOS=:AMMPOS:  AND AMMMODNR=:AMMMODNR:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData).Replace("''", "");
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public DataSet QAMD04(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "SELECT X.* FROM  AMMODUL X "
                            + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:  AND  AMMLFDNR=:AMMLFDNR:  AND  AMMPOS=:AMMPOS:  AND AMMMODNR<>:AMMMODNR:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData).Replace("''", "");
            SResult = Connect2Proxy(or1);
            SResult.Tables[0].TableName = TableName;
            return SResult;
        }
        public void DAMD00(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM  AMMODUL"
              + " WHERE AMMMANDANT=:AMMMANDANT: ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
        public void DAMD01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM  AMMODUL "
             + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:  AND  AMMLFDNR=:AMMLFDNR:  AND  AMMPOS=:AMMPOS:  AND AMMMODNR=:AMMMODNR:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
        public void DAMD02(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM  AMMODUL"
              + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:  AND  AMMLFDNR=:AMMLFDNR:  AND  AMMPOS=:AMMPOS:  ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);
        }
        public void DAMD03(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM  AMMODUL"
              + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:  AND  AMMLFDNR=:AMMLFDNR:  ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }

        public void DAMD04(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM  AMMODUL"
              + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:    ";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
        public void DAMD05(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "DELETE FROM  AMMODUL   "
                             + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:  AND  AMMLFDNR=:AMMLFDNR:  AND  AMMPOS=:AMMPOS:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData).Replace("''", "");
            Connect2Proxy(or1);

        }
        public void UpdateAMMODUL(DataRow dwData, int option = 1)
        {
            if (option == 0)
            {
                switch (app.company)
                {

                    case "YGR":
                    case "SXN":
                    case "TST":
                    case "UBT":
                    default:
                        UAMD01(dwData); break;
                        break;
                }
            }

        }
        public void UAMD01(DataRow dwData)
        {
            or1 = OracleDB.CreateCommand();
            or1.CommandText = "UPDATE AMMODUL SET AMMMANDANT=:AMMMANDANT:,AMMNRKRS=:AMMNRKRS:,AMMLFDNR=:AMMLFDNR:,AMMPOS=:AMMPOS:,AMMMODNR=:AMMMODNR:,AMMBEZ=:AMMBEZ:,AMMTYP=:AMMTYP:,AMMART=:AMMART:,AMMLIEFNR=:AMMLIEFNR:,AMMHERST=:AMMHERST:,AMMINVNR=:AMMINVNR:,AMMINVPOS=:AMMINVPOS:,AMMABSCHKZ=:AMMABSCHKZ:,AMMABREITEV=:AMMABREITEV:,AMMABREITEB=:AMMABREITEB:,AMMFLMIN=:AMMFLMIN:,AMMFLMAX=:AMMFLMAX:,AMMSYSFL=:AMMSYSFL:,AMMANSRUND=:AMMANSRUND:,AMMRAKELKZ=:AMMRAKELKZ:,AMMLAENGE=:AMMLAENGE:,AMMLTRV1=:AMMLTRV1:,AMMLTRB1=:AMMLTRB1:,AMMBHSYS1=:AMMBHSYS1:,AMMBHMAX1=:AMMBHMAX1:,AMMLTRV2=:AMMLTRV2:,AMMLTRB2=:AMMLTRB2:,AMMBHSYS2=:AMMBHSYS2:,AMMBHMAX2=:AMMBHMAX2:,AMMLTRV3=:AMMLTRV3:,AMMLTRB3=:AMMLTRB3:,AMMBHSYS3=:AMMBHSYS3:,AMMBHMAX3=:AMMBHMAX3:,AMMNETFA=:AMMNETFA:,AMMFILLER=:AMMFILLER:,AMMAENDZL=:AMMAENDZL:,AMMAENDBEN=:AMMAENDBEN:,AMMAENDDAT=:AMMAENDDAT:,AMMNEUBEN=:AMMNEUBEN:,AMMNEUDAT=:AMMNEUDAT:"
                + " WHERE AMMMANDANT=:AMMMANDANT: AND AMMNRKRS=:AMMNRKRS:  AND  AMMLFDNR=:AMMLFDNR:  AND  AMMPOS=:AMMPOS:  AND AMMMODNR=:AMMMODNR:";
            or1.CommandText = INTEXDBC.InjectData(or1.CommandText, dwData);
            Connect2Proxy(or1);

        }
    }
}
